/*
 * Created on 2005-10-9
 *
 */
package com.hd123.rumba.user;

import java.sql.Blob;
import java.util.Date;
import java.util.List;
import java.util.Vector;

import com.hd123.rumba.exception.BusinessException;
import com.hd123.rumba.runtime.IBaseEntity;
import com.hd123.rumba.util.AccessMode;

/**
 * 用户 | 实体 | 接口类
 * <p>
 * 
 * BK = domain + login (state != VALUE_STATE_DELETED)
 * 
 * @author caili
 */
public interface IUser extends IBaseEntity {

  /** @deprecated */
  public static String CAPTION_CLASS = CUser.CAPTION_CLASS;
  /** @deprecated */
  public static String CAPTION_USER = CUser.CAPTION_USER;

  /** @deprecated */
  public static String CAPTION_LOGIN = CUser.CAPTION_LOGIN;

  public void setLogin(String login) throws BusinessException;

  public String getLogin() throws BusinessException;

  /** @deprecated */
  public static String CAPTION_PASSWORD = CUser.CAPTION_PASSWORD;

  public void setPassword(String password) throws BusinessException;

  public String getPassword() throws BusinessException;

  /** @deprecated */
  public static String CAPTION_ONLINE = CUser.CAPTION_ONLINE;

  public void setOnline(Boolean online) throws BusinessException;

  public Boolean getOnline() throws BusinessException;

  /** @deprecated */
  public static String CAPTION_VALIDFROM = CUser.CAPTION_VALIDFROM;

  public void setValidFrom(Date validFrom) throws BusinessException;

  public Date getValidFrom() throws BusinessException;

  /** @deprecated */
  public static String CAPTION_VALIDTO = CUser.CAPTION_VALIDTO;

  public void setValidTo(Date validTo) throws BusinessException;

  public Date getValidTo() throws BusinessException;

  /** @deprecated */
  public static String CAPTION_REMARK = CUser.CAPTION_REMARK;

  public void setRemark(String remark) throws BusinessException;

  public String getRemark() throws BusinessException;

  /** @deprecated */
  public static String CAPTION_NAME = CUser.CAPTION_NAME;

  public void setName(String name) throws BusinessException;

  public String getName() throws BusinessException;

  /** @deprecated */
  public static final String CAPTION_PROFILE = CUser.CAPTION_PROFILE;

  public IProfile getProfile() throws BusinessException;

  public void setProfile(IProfile profile) throws BusinessException;

  /** @deprecated */
  public static final String CAPTION_DEPARTMENT = CUser.CAPTION_DEPARTMENT;

  public IDepartment getDepartment() throws BusinessException;

  public void setDepartment(IDepartment department) throws BusinessException;

  /** @deprecated */
  public static final String CAPTION_IMAGE = CUser.CAPTION_IMAGE;

  public Blob getImage() throws BusinessException;

  public void setImage(Blob image) throws BusinessException;

  public Vector getPermissionIds() throws BusinessException;

  /** 令牌PIN码 */
  public String getTokenPin() throws BusinessException;

  public void setTokenPin(String tokenPin) throws BusinessException;

  /** 令牌序列号 */
  public String getTokenSn() throws BusinessException;

  public void setTokenSn(String tokenSn) throws BusinessException;

  /** 是否启用令牌 */
  public Boolean getUseToken() throws BusinessException;

  public void setUseToken(Boolean useToken) throws BusinessException;

  /**
   * 判断用户是否具有指定的权限。
   * 
   * @param permissionId
   *          指定权限id，允许传入null，将返回false。
   * @return
   */
  public boolean hasPermission(String permissionId) throws BusinessException;

  /**
   * 判断用户是否具有指定的权限。
   * 
   * @param pe
   *          指定的权限表达式。允许传入null，将返回false。
   * @return
   */
  public boolean hasPermissions(PE permissionExpression) throws BusinessException;

  /**
   * 判断用户是否具有指定的权限。
   * 
   * @param permId
   *          指定权限id，允许传入null，将返回true。
   * @return
   * @throws BusinessException
   */
  public boolean hasPerm(String permId) throws BusinessException;

  /**
   * 判断用户是否具有指定的权限。
   * 
   * @param pe
   *          指定权限表达式，允许传入null，将返回true。
   * @return
   * @throws BusinessException
   */
  public boolean hasPerm(PE pe) throws BusinessException;

  public boolean hasAssignedPermission(String permissionId) throws BusinessException;

  /**
   * 取得当前用户对于指定的字段的访问模式（不可见|只读|读写）
   * 
   * @see AccessMode
   * @param fieldPermId
   *          指定的字段权限ID。
   * @return 取值：{@link AccessMode#INVISIBLE}|{@link AccessMode#READONLY}|{@link AccessMode#READWRITE}
   * @throws BusinessException
   */
  public int getFieldAccessMode(String fieldPermId) throws BusinessException;

  public String getFullLogin() throws BusinessException;

  public String getCodeName() throws BusinessException;

  public String getNameCode() throws BusinessException;

  public void encodePassword(String fpassword) throws BusinessException;

  public static final String PERMISSION_EDIT = "用户.编辑权"; /* "user.edit"; */
  public static final String PERMISSION_VIEW = "用户.查看权";/* "user.view"; */

  public void addToPermissionMap(IPermission perm) throws BusinessException;

  /**
   * 添加权限。
   * 
   * @param permCodes
   *          权限代码列表。
   * @throws BusinessException
   */
  public void addToPermissionMap(List<String> permCodes) throws BusinessException;

  public void removeFromPermissionMap(IPermission perm) throws BusinessException;
}
